package club.jdiy.core.convert;

import club.jdiy.utils.DateUtils;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
@SuppressWarnings("unused")
class LocalDateTimeConverter extends Converter {
    private final LocalDateTime source;

    public LocalDateTimeConverter(LocalDateTime source) {
        this.source = source;
    }
    public LocalDateTimeConverter(Timestamp source) {
        this.source = source.toLocalDateTime();
    }

    @Override
    public LocalDateTime getSource() {
        return source;
    }

    @Override
    public Long getLong() {
        return source.toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
    }


    @Override
    public String getString() {
        return DateUtils.fmt_datetime.format(source);
    }

    @Override
    public Date getDate() {
        return Date.from(source.toInstant(ZoneOffset.ofHours(8)));
    }

    @Override
    public LocalDate getLocalDate() {
        return source.toLocalDate();
    }

    @Override
    public LocalDateTime getLocalDateTime() {
        return source;
    }

}
